<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <div id="app"></div>
    <!-- 1.引入依赖 -->
    <script src="../react/react.development.js"></script>
    <script src="../react/react-dom.development.js"></script>
    <script src="../react/babel.min.js"></script>
    <!-- 2.开始开发 -->
    <script type="text/babel">
      class App extends React.Component {
        constructor() {
          super()

          this.state = {
            names: ["nba", "cba", "abc", "cook"],
            numbers: [110, 123, 50, 32, 55, 10, 8, 333],
          }
        }

        render() {
          return (
            <div>
              <h2>列表渲染 map</h2>
              {
                this.state.names.map(item => {
                  return <li>{item}</li>
                })
              }

              <h2>数字列表(过滤1)</h2>
              {
                this.state.numbers
                .filter(item => {
                  return item >= 50
                })
                .map(item => {
                  return <li>{item}</li>
                })
              }

              <h2>数字列表(过滤2)</h2>
              <ul>
                {
                  this.state.numbers
                  .filter(item => item >= 50)
                  .map(item => (
                    <li>{item}</li>
                  ))
                }
              </ul>

              <h2>数字列表(截取)</h2>
              <ul>
                {
                  this.state.numbers.slice(0, 4).map(item => {
                    return <li>{item}</li>
                  })
                }
              </ul>
            </div>
          )
        }
      }
      ReactDOM.render(<App />, document.getElementById("app"))
    </script>
  </body>
</html>
